package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.ProcurementProduct;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProcurementProductVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "采购单id")
    private Integer procurementId;

    @ApiModelProperty(value = "请购物品主id")
    private Integer requisitionProductId;

    @ApiModelProperty(value = "物品spu_id")
    private Integer productSpuId;

    @ApiModelProperty(value = "对内购买数量")
    private Double productBuyNum;

//    @ApiModelProperty(value = "对外购买数量")
//    private Double financeBuyNum;

    @ApiModelProperty(value = "仓库单位id")
    private Integer unitId;

//    @ApiModelProperty(value = "采购单位id")
//    private Integer financeUnitId;
//
//    @ApiModelProperty(value = "默认转换率")
//    private Double conversionRate;

    @ApiModelProperty(value = "单价")
    private Double price;

    @ApiModelProperty(value = "总价")
    private Double productBuyPrice;

    @ApiModelProperty(value = "实际到货数量")
    private Double actualNum;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ProcurementProduct convert(ProcurementProductVO vo) {
        ProcurementProduct entity = new ProcurementProduct();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ProcurementProduct> convertList(List<ProcurementProductVO> list) {
        List<ProcurementProduct> resultList = new ArrayList<>();
        for (ProcurementProductVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
